package Comunicator;

import Entities.Scene;
import java.io.BufferedOutputStream;
import java.io.ObjectOutputStream;
import java.io.OutputStream;
import java.net.Socket;

public class OutputComunicatorCliente1 extends Thread implements OutputComunicator {

    private String ip;
    private Scene scene;

    OutputComunicatorCliente1(String ip, Scene scene) {
        this.ip = ip;
        this.scene = scene;
    }

    @Override
    public void run() {
        while (true) {
            try {
                Socket socket = new Socket(ip, 5003);
                OutputStream outputStream = socket.getOutputStream();
                ObjectOutputStream objectOutputStream = new ObjectOutputStream(new BufferedOutputStream(outputStream));
                objectOutputStream.writeObject(scene);
                objectOutputStream.flush();
                objectOutputStream.close();
            } catch (Exception e) {
            }
        }
    }
}
